<?php
define('AJAX',1);
require_once('global.php');

S::gp(array('action','jumpurl'));

if($action == 'loginbar'){ //全站登录条
    if($windid){
        $html = '欢迎 <b>'.$windid.'</b>, <a href="http://i.sudingke.com/' .$loginouturl. '&jumpurl=\' +encodeURIComponent(window.top.location.href)+ \'">退出</a>';
    }else{
        $html = '<a href="http://i.sudingke.com/register.php">立即注册</a> <span class="pipe">|</span> <a href="http://i.sudingke.com/login.php" onClick="return loginWindow()">登录</a>';
    }
    echo("function loginWindow(){if(!\$.dialog){return false;}else{\$.dialog.open('http://i.sudingke.com/sudingke.php?action=ajaxlogin&jumpurl=' +encodeURIComponent(window.top.location.href),{'title': '登录 - 速订客', 'width': 360, 'height': 185, 'lock': true});return false;}}");
    echo("document.write('{$html}');");
    exit;
}
else if($action == 'ajaxlogin'){
    if(empty($jumpurl)){
        $jumpurl = 'http://google.com';
    }
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>登录</title>
<script src="http://i.sudingke.com/js/pw_ajax.js" type="text/javascript"></script>
<style>
*{font-size:14px;}
label{height:32px;line-height:32px;}
label span{width:80px;display:inline-block;}
input{border:1px #aaa solid;width:200px;padding:4px;}
a{color:#666;}
</style>
</head>
<body>
<form action="http://i.sudingke.com/login.php" name="loginForm"  method="post" onsubmit="return loginSubmit()">
  <input type="hidden" name="ajax" value="1" />
  <input type="hidden" name="step" value="2" />
  <input type="hidden" name="jumpurl" value="<?=htmlspecialchars($jumpurl);?>" />

  <label><span>用户名： </span><input type="text" name="pwuser" /></label>
    <br />
  <label><span>密 &nbsp;码： </span><input type="text" name="pwpwd" /></label>
    <br />
  <center style="display:block;height:35px;padding:10px;border-bottom:1px #ccc dotted;">
    <button type="submit">登 录</button> 还没有账户？<a href="http://i.sudingke.com/register.php" target="top">立即注册</a>
  </center>
  <p align="right">
    <a onclick="window.open('http://i.sudingke.com/login.php?action=weibologin&amp;type=sinaweibo&amp;from='+self.location.href, 'weiboLogin', 'height=520, width=850, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no');" href="javascript:;"><img alt="新浪api登录接口" src="http://www.tuanle.cn/public/attachment/201203/17/15/4f64396822524.png"></a>
    <a onclick="window.open('http://i.sudingke.com/login.php?action=weibologin&amp;type=qzone&amp;from='+self.location.href, 'weiboLogin', 'height=520, width=850, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no');" href="javascript:;" title="使用QQ帐号登录"><img alt="QQ登录插件" src="http://www.tuanle.cn/public/attachment/201203/17/15/4f643977758ee.png"></a>
  </p>
</form>
</body>
</html>
<script type="text/javascript">
document.name = 'sudingke.com';
function loginSubmit() {
    var obj = document.loginForm;
    var url = 'http://i.sudingke.com/login.php';
    ajax.send(url, obj, function(){
        var rText = ajax.request.responseText.split("\t");
        //alert(rText[0]);
        if (rText[0] == 'error') {
            alert(rText[1]);
        } else if (rText[0] == 'success') {
            //成功后跳转
            top.location = rText[1];
        } else {
            alert('other');
        }

        window.top.parentRun(rText[1]);
    });
    return false;
}
</script>
<?php
}
else if($action == 'userinfo') {
    p($GLOBALS);
}

function p($var){
    echo '<pre>';
    print_r($var);
    echo '</pre>';
}
?>